package com.b2c.oa;

import org.springframework.core.io.support.PropertiesLoaderUtils;

import java.util.Properties;

/**
 * 描述：
 *
 * @author qlp
 * @date 2019-11-08 13:58
 */
public class DataConfigObject {
    //创建 SingleObject 的一个对象
    private static DataConfigObject instance = new DataConfigObject();

    private Integer pageSize = 10;
    private String pddClientId = "";
    private String pddClientSecret = "";
    private Integer autoUpdateTaoOrder = 0;//是否开启淘系订单自动更新 1开启 0关闭

    //让构造函数为 private，这样该类就不会被实例化
    private DataConfigObject() {
        try {
            Properties properties = PropertiesLoaderUtils.loadAllProperties("config.properties");
            pageSize = Integer.parseInt(properties.getProperty("pageSize"));
            pddClientId = properties.getProperty("pdd_client_id");
            pddClientSecret = properties.getProperty("pdd_client_secret");
            autoUpdateTaoOrder = Integer.parseInt(properties.getProperty("auto_update_order"));
        } catch (Exception e) {
            pageSize = 10;
        }
    }

    //获取唯一可用的对象
    public static DataConfigObject getInstance() {
        return instance;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public String getPddClientId(){
        return pddClientId;
    }

    public String getPddClientSecret(){
        return pddClientSecret;
    }

    public Integer getAutoUpdateTaoOrder() {
        return autoUpdateTaoOrder;
    }
}
